package com.fhz.a2102shopjava.di;

import com.fhz.a2102shopjava.anno.LiveDataCallAdapterFengService;
import com.fhz.a2102shopjava.anno.LiveDataCallAdapterRetrofit;
import com.fhz.a2102shopjava.anno.OKHttpCallAdapterFengService;
import com.fhz.a2102shopjava.anno.OkHttpallAdapterRetrofit;
import com.fhz.a2102shopjava.api.FengService;
import com.fhz.a2102shopjava.api.OkHttpCallAdapterFengServiceApi;
import com.fhz.a2102shopjava.util.RetrofitUtil;

import javax.inject.Inject;
import javax.inject.Singleton;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import dagger.hilt.InstallIn;
import dagger.hilt.android.components.ActivityComponent;
import dagger.hilt.components.SingletonComponent;
import retrofit2.Retrofit;

/**
 * 时间:2023/8/15
 *
 * @author Mr.Feng
 * 简述: 网络工具注入
 */
@Module
@InstallIn(SingletonComponent.class)
public class HttpModule {

    @Provides
    @OKHttpCallAdapterFengService
    public static OkHttpCallAdapterFengServiceApi provideOkHttpCallAdapterFengService(@OkHttpallAdapterRetrofit Retrofit retrofit) {
        return retrofit.create(OkHttpCallAdapterFengServiceApi.class);
    }

    @Provides
    @LiveDataCallAdapterFengService
    public static FengService provideFengService(@LiveDataCallAdapterRetrofit Retrofit retrofit) {
         return retrofit.create(FengService.class);
    }

    /**
     * 给当前module提供Retrofit
     * @return
     */
    @Provides
    @OkHttpallAdapterRetrofit
    public static Retrofit getRetrofit(){
        return  RetrofitUtil.getInstance().getOkHttpCallAdapterRetrofit();
    }

    @Provides
    @LiveDataCallAdapterRetrofit
    public static Retrofit getLiveDataCallAdapterRetrofit(){
        return  RetrofitUtil.getInstance().getLiveDataCallAdapterRetrofit();
    }





}   
